package com.xuetang9.t9.hotel.mapper;

import com.xuetang9.t9.hotel.beans.CommodityExpense;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Pang
 */
public interface ICommodityExpenseMapper {

    /**
     * 新增商品消费记录表
     * @param commodityExpense
     * @return
     */
    @Insert("INSERT INTO g_commodityexpense(bill_id,arrive_id,attribute) VALUES(#{billId},#{arriveId},#{attribute})")
    int insert(CommodityExpense commodityExpense);


    /**
     * 根据消费明细表删除商品消费表
     * @param billId
     * @return
     */
    @Delete("DELETE FROM g_commodityexpense WHERE bill_id=#{id}")
    int deleteByBillId(@Param("id") Long billId);

    /**
     * 根据商品编号删除商品消费明细
     * @param commId
     * @return
     */
    @Delete("DELETE FROM g_commodityexpense WHERE arrive_id=#{id}")
    int deleteByArriveId(@Param("id") Integer commId);


    /**
     * 更新商品消费记录表
     * @param commodityExpense
     * @return
     */
    @Update("UPDATE g_commodityexpense SET attribute=#{Attribute} WHERE bill_id=#{billId} AND arrive_id=#{arriveId}")
    int update(CommodityExpense commodityExpense);

    /**
     * 根据账单明细编号查询商品明细表
     * @param billId
     * @return
     */
    @Select("SELECT * FROM g_commodityexpense WHERE bill_id =#{billId}")
    List<CommodityExpense> selectByBillId(@Param("billId") Long billId);

    /**
     * 根据账单明细编号查询商品明细表总记录条数
     * @param billId
     * @return
     */
    @Select("SELECT COUNT(*) FROM g_commodityexpense WHERE bill_id =#{billId}")
    Long selectByCount(Integer billId);
}
